package com.ty.user.starter.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ty.user.starter.entity.Log;
import com.ty.user.starter.service.LogService;
import com.ty.user.starter.util.R;
import com.ty.user.starter.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 系统日志表 前端控制器
 * </p>
 *
 * @author minku
 * @since 2021-10-21
 */
@RestController
@RequestMapping("/starter/log")
public class LogController {
    private final LogService logService;

    @Autowired
    public LogController(LogService logService) {
        this.logService = logService;
    }

    @RequestMapping(value = "page")
    public R<Page<Log>> page(int start, int limit, Log sysLog) {
        QueryWrapper<Log> queryWrapper = new QueryWrapper<>(sysLog);
        queryWrapper.orderByDesc("create_date");
        Page<Log> page = logService.page(new Page<>(start, limit), queryWrapper);
        return ResponseUtil.success(page);
    }
}
